package com.disgnpattern.learn.chapter1;

/**
 * @author dxy
 * @version 1.0
 * @date 2021/10/21 11:14
 * @decripton 运算工厂
 */
public class OperationFactory {

    public static AbstractOperation getOperation(String operation) throws Exception {
        switch (operation) {
            case "+":
                return new OperationAdd();
             case   "-":
                return new OperationSub();
            case "*":
                return new OperationMul();
            case "/":
                return new OperationDiv();
            default:
                throw new Exception("不支持的运算符号");
        }
    }
}
